//
//  DrawRectView.m
//  Core Graphics Code
//
//  Created by liboxiang on 2019/1/10.
//  Copyright © 2019 liboxiang. All rights reserved.
//

#import "DrawRectView.h"

@implementation DrawRectView

- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    // **********您的绘图代码在这里********** // 2
    CGContextSetRGBFillColor(context,1,0,0,1); // 3
    CGContextFillRect(context,CGRectMake(0,100,200,100)); // 4
    CGContextSetRGBFillColor(context,0,0,1,.5); // 5
    CGContextFillRect(context,CGRectMake(0,100,100,200));
    
    CGContextMoveToPoint(context, 0, 100);
    //直线
    CGContextAddLineToPoint(context, 100, 100);
    
    CGPoint lines[] = {CGPointMake(150, 100),CGPointMake(200, 100),CGPointMake(200, 150),CGPointMake(180, 100),CGPointMake(300, 140),CGPointMake(250, 120),CGPointMake(300, 100),};
    CGContextAddLines(context, lines, sizeof(lines)/sizeof(lines[0]));
    
    //弧
    CGContextAddArc(context, 100, 200, 100, 0, M_PI, 0);
    CGContextAddArcToPoint(context, 50, 150, 300, 500, 100);
    
    //曲线
    CGContextAddCurveToPoint(context, 50, 500, 200, 500, 250, 400);
    CGContextAddQuadCurveToPoint(context, 100, 600, 200, 300);
    CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
    CGContextStrokePath(context);
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
